<!DOCTYPE html>
<html lang="zh-CN">
  <head>
	  <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'修改数据字典详情信息', styles:'bootstrap,font-awesome,animate,style,dtvalidate,awesome-checkbox'}){%>
	  <style type="text/css">
		  body{padding-top:10px;}
	  </style>
	  <%}%>
  </head>
  <body>
	<!-- START 内容部分 -->
	<div class="container">
		<form class="form-horizontal" id="info-form" method="post">
				<!-- id -->
			<input type="hidden" name="id" value="${dictDetail.id}"/>

			<div class="form-group">
				<label class="col-sm-2 control-label text-right">所属分类</label>
				<div class="col-sm-6">
					<select id="dictType" name="dictType" class="form-control" valid="r" validTitle="所属分类" validInfoArea="dictType_info_area" >
						<option value="">选择所属</option>
						<%for(var dict in dictTypes){%>
						<option value="${dict.id}" <%if(dictDetail.dictType == dict.id){print("selected");}%>>${dict.name}</option>
						<%}%>
					</select>
				</div>
				<div class="col-sm-4"><p class="help-block" id="dictType_info_area"></p></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">名称</label>
				<div class="col-sm-6">
					<input type="text" id="detailName" name="detailName" class="form-control" valid="r" validTitle="名称" validInfoArea="detailName_info_area" value="${dictDetail.detailName}"/>
				</div>
				<div class="col-sm-4"><p class="help-block" id="detailName_info_area"></p></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">编码</label>
				<div class="col-sm-6">
					<input type="text" id="detailCode" name="detailCode" class="form-control" valid="r|english_number" validTitle="编码" validInfoArea="detailCode_info_area" value="${dictDetail.detailCode}"/>
				</div>
				<div class="col-sm-4"><p class="help-block" id="detailCode_info_area"></p></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">类型</label>
				<div class="col-sm-6">
					<input type="text" id="detailType" name="detailType" class="form-control"  value="${dictDetail.detailType}"/>
				</div>
				<div class="col-sm-4"></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">状态</label>
				<div class="col-sm-6">
					<div class="radio radio-primary radio-inline">
						<input type="radio" id="detailState-1" name="detailState" valid="r" validTitle="状态" validInfoArea="detailState_info_area" value="1" ${decode(dictDetail.detailState,1,"checked","")}/>
						<label for="detailState-1"> 启用 </label>
					</div>
					<div class="radio radio-primary radio-inline">
						<input type="radio" id="detailState-0" name="detailState" valid="r" validTitle="状态" validInfoArea="detailState_info_area" value="0" ${decode(dictDetail.detailState,0,"checked","")}/>
						<label for="detailState-0"> 禁用</label>
					</div>
				</div>
				<div class="col-sm-4"><p class="help-block" id="detailState_info_area"></p></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">备注</label>
				<div class="col-sm-6">
					<input type="text" id="detailRemark" name="detailRemark" class="form-control" value="${dictDetail.detailRemark}"/>
				</div>
				<div class="col-sm-4"></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">排序号</label>
				<div class="col-sm-6">
					<input type="text" id="detailSort" name="detailSort" class="form-control" valid="r|number" validTitle="排序号" validInfoArea="detailSort_info_area" value="${dictDetail.detailSort}"/>
				</div>
				<div class="col-sm-4"><p class="help-block" id="detailSort_info_area"></p></div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="save-btn btn btn-primary">
						<i class="fa fa-save"></i> 保存
					</button>
				</div>
			</div>
		</form>
	</div>
	<!-- END 内容部分 -->
	
	<!-- START 公共脚本 -->
    <%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,dtvalidate,dtvalidate-lang-zh_cn'}){}%>
	<!-- END 公共脚本 -->
	<script>
	var cvalidator;
	$(function(){
		//初始化验证器
		cvalidator = $.fn.dlshouwen.validator.init($('#info-form'));
		
		//提交表单
		$('.save-btn').on('click',function(){
			if(!cvalidator.validResult()){
				$.fn.dlshouwen.validator.tools.toast('验证失败！', 'error', 2000);
				return;
			}
			
			//数据提交
			$.post('${ctxPath}/dictdetail/info/usave.do',$('#info-form').serialize(),function(data){
				if( data.ok ){
					parent.layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']}, function(){
						parent.$dictdetailtable.bootstrapTable('refresh');
						parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
					});
				}else{
					parent.layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
				}
			});
		});
    });
    </script>
  </body>
</html>